package cn.lingyangwl.agile.food.model.rqrs.goods.category;

import cn.lingyangwl.framework.tool.core.CollectionUtils;
import cn.lingyangwl.framework.tool.core.tree.TreeNode;
import lombok.Getter;
import lombok.Setter;

import java.util.List;

/**
 * @author shenguangyang
 */
@Getter
@Setter
public class GoodsCategoryTreeResp extends GoodsCategoryBase implements TreeNode<Long, GoodsCategoryTreeResp> {
    private Long id;
    private List<GoodsCategoryTreeResp> children;

    /**
     * 前端数据树中的key
     */
    public String getKey() {
        return String.valueOf(this.id);
    }

    /**
     * 前端数据树中的value
     */
    public String getValue() {
        return String.valueOf(this.id);
    }

    /**
     * 前端数据树中的title
     */
    public String getTitle() {
        return this.getName();
    }

    @Override
    public Long treeId() {
        return this.id;
    }

    @Override
    public void treeId(Long id) {
        this.id = id;
    }

    @Override
    public Long treeParentId() {
        return this.getParentId();
    }

    @Override
    public void treeParentId(Long parentId) {
        this.setParentId(parentId);
    }

    @Override
    public List<GoodsCategoryTreeResp> children() {
        return CollectionUtils.isEmpty(children) ? null : children;
    }

    @Override
    public String name() {
        return this.getName();
    }

    @Override
    public void children(List<GoodsCategoryTreeResp> children) {
        this.children = children;
    }

    @Override
    public Integer sortNo() {
        return this.getSortNo();
    }
}
